// const moment = require("../../script/moment/moment");

var ns, toast;
var app = new Vue({
    el: '#app',
    data: {
        pageindex: 0,
        pagesize: 10,
        product_list: [],//商品销量排行
        can_scroll:false,
        current_item_length: 0,
    },
    methods: {
        // 商品销量
        get_data: function () {
            var that = this;
            that.can_scroll = false;
            // that.product_list = [];
            var option={};
            option.action='orderitemrank';
            option.pageindex= that.pageindex;
            option.pagesize=that.pagesize;
            console.log(JSON.stringify(option));
            ns.post(option,function (succeed, data, err) {
                if (succeed) {
                    if (data.list.rows.length == that.pagesize) {
                        that.can_scroll = true;
                    }
                    if (that.pageindex == 0) {
                        that.product_list = data.list.rows;
                    } else {
                        that.product_list = that.product_list.concat(data.list.rows);
                    }
                    that.current_item_length = that.product_list.length;

                } else {
                    that.product_list = [];
                    that.current_item_length = 0;
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            });
        },
    },
});

apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    ns.init_pull();
    app.get_data();

}
